<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--引入vue核心js-->
    <script type="text/javascript" src="./plugins/vue/dist/vue.min.js"></script>
    <!--引入axios的核心js-->
    <script type="text/javascript" src="./plugins/axios/dist/axios.min.js"></script>
    <!--引入公共的js-->
    <script type="text/javascript" src="./js/common.js"></script>
</head>
<body>
    <div id="app"></div>
</body>
<script type="text/javascript">
    new Vue({
        el:"#app",
        mounted(){
            //获取当前url地址?后面的参数
           let param =  getParam();
           console.debug(param);
           //通过授权码获取token
            this.$http.post("/wechat/handleCallBack", param).then(res => {
                let {success, msg, resultObj} = res.data;
                //如果成功，并且openid有值
                if (success && resultObj.openid) {
                    location.href = "binder.html?openid=" + resultObj.openid;
                } else if (success && resultObj.token && resultObj.loginUser) {
                    localStorage.setItem("token", resultObj.token);
                    localStorage.setItem("loginUser", JSON.stringify(resultObj.loginUser));
                    location.href = "/index.html";
                }
            });
        }
    })
</script>
</html>